home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-12-24 | 1.6 KB | 90 lines | [TEXT/PJMM] |
- unit MatrixFunctions;
-
- interface
-
- uses
-
- Globals;
-
-
- procedure matrixfunctions (var matrix: hdlsinglearraymatrix; var mrows, ncols: longint; var matrixoper: string30; var realresult: extended);
-
- procedure matrixtranspose (var matrix: hdlsinglearraymatrix; var mrows, ncols: longint; var matrixoper: string30);
-
-
- implementation
-
-
- procedure matrixfunctions;
-
- var
- i, a, b: longint;
- bstring: str255;
- x: extended;
- showwind: boolean;
-
- begin
-
- matrix^^[1] := mrows;
- matrix^^[2] := ncols;
-
- for i := 3 to mrows * ncols + 2 do
- begin
- x := matrix^^[i];
- if matrixoper = 'ln' then
- x := ln(x);
- if matrixoper = 'log' then
- x := ln(x) / ln(10);
- if matrixoper = 'exp' then
- x := exp(x);
- if matrixoper = 'sin' then
- x := sin(x);
- if matrixoper = 'abs' then
- x := abs(x);
- if matrixoper = 'sqr' then
- x := sqr(x);
- if matrixoper = 'sqrt' then
- x := sqrt(x);
- if matrixoper = plus then
- x := x;
- if matrixoper = minus then
- x := -x;
- matrix^^[i] := x;
- end;
-
- end;
-
- procedure matrixtranspose;
-
- var
- i, j, l: longint;
- dummatrix: hdlsinglearraymatrix;
-
- begin
-
- mrows := round(matrix^^[1]);
- ncols := round(matrix^^[2]);
-
- blocksize := longint(10 * mrows * ncols + 20);
- dummatrix := hdlsinglearraymatrix(NewHandle(blocksize));
-
- for i := 1 to mrows * ncols do
- dummatrix^^[i] := matrix^^[2 + i];
-
- matrix^^[1] := ncols;
- matrix^^[2] := mrows;
-
- l := 2;
- for i := 1 to ncols do
- for j := 1 to mrows do
- begin
- l := l + 1;
- matrix^^[l] := dummatrix^^[(j - 1) * ncols + i];
- end;
-
- DisposHandle(handle(dummatrix));
-
- end;
-
-
- end.